package com.macro.mall.portal.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BmsTourismProjectActivitiesDetail;
import com.macro.mall.dto.BmsTourismProjectActivitiesParam;
import com.macro.mall.model.BmsTourismProjectActivities;
import com.macro.mall.portal.service.BmsTourismProjectActivitiesService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Controller
@Api(tags = "BmsTourismProjectActivitiesController")
@Tag(name = "BmsTourismProjectActivitiesController", description = "文旅项目-文旅项目-活动")
@RequestMapping("/tourismProjectActivities")
public class BmsTourismProjectActivitiesController {

    @Autowired
    private BmsTourismProjectActivitiesService bmsTourismProjectActivitiesService;

    @ApiOperation("分页查询文旅项目-活动")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsTourismProjectActivities>> getList(@RequestBody BmsTourismProjectActivitiesParam bmsTourismProjectActivitiesParam) {
        List<BmsTourismProjectActivities> bmsTourismProjectActivitiesList = bmsTourismProjectActivitiesService.getList(bmsTourismProjectActivitiesParam);
        return CommonResult.success(CommonPage.restPage(bmsTourismProjectActivitiesList));
    }


    @ApiOperation("根据id获取文旅项目-活动详情")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsTourismProjectActivitiesDetail> getItem(@PathVariable Long id) {
        BmsTourismProjectActivitiesDetail bmsTourismProjectActivitiesDetail = bmsTourismProjectActivitiesService.getItem(id);
        return CommonResult.success(bmsTourismProjectActivitiesDetail);
    }

    @ApiOperation("获取热门文旅项目-活动")
    @RequestMapping(value = "/getHotProjectActivities", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsTourismProjectActivitiesDetail>> getHotProjectActivities(@RequestBody BmsTourismProjectActivitiesParam bmsTourismProjectActivitiesParam) {
        List<BmsTourismProjectActivitiesDetail> hotProjectActivities = bmsTourismProjectActivitiesService.getHotProjectActivities(bmsTourismProjectActivitiesParam);
        return CommonResult.success(CommonPage.restPage(hotProjectActivities));
    }

    @ApiOperation("获取推荐文旅项目-活动")
    @RequestMapping(value = "/getTestimonialsProjectActivities", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsTourismProjectActivitiesDetail>> getTestimonialsProjectActivities(@RequestBody BmsTourismProjectActivitiesParam bmsTourismProjectActivitiesParam) {
        List<BmsTourismProjectActivitiesDetail> testimonialsProjectActivities = bmsTourismProjectActivitiesService.getTestimonialsProjectActivities(bmsTourismProjectActivitiesParam);
        return CommonResult.success(CommonPage.restPage(testimonialsProjectActivities));
    }

    @ApiOperation("获取小程序用户报名文旅项目-活动")
    @RequestMapping(value = "/getReserveProjectActivities", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsTourismProjectActivitiesDetail>> getReserveProjectActivities(HttpServletRequest request, @RequestBody BmsTourismProjectActivitiesParam bmsTourismProjectActivitiesParam) {
        List<BmsTourismProjectActivitiesDetail> reserveProjectActivities = bmsTourismProjectActivitiesService.getReserveProjectActivities(bmsTourismProjectActivitiesParam,request);
        return CommonResult.success(CommonPage.restPage(reserveProjectActivities));
    }

    @ApiOperation("获取文旅项目-活动报名人数")
    @RequestMapping(value = "/getActivitiesHasRegistrationNum", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Integer> getActivitiesHasRegistrationNum(@RequestParam(value = "activitiesId", required = false) Long activitiesId) {
        return CommonResult.success(bmsTourismProjectActivitiesService.getActivitiesHasRegistrationNum(activitiesId));
    }

    @ApiOperation("判断是否已报名")
    @RequestMapping(value = "/isHasApplicant/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<?> isHasApplicant(@PathVariable Long id) {
        return CommonResult.success(bmsTourismProjectActivitiesService.isHasApplicant(id));
    }

}
